
from functools import partial
import keyboard
import win32con
import win32api

#这是按键控制的
def abc(x):
    a = keyboard.KeyboardEvent(event_type='down', scan_code=57, name='space')
    b = keyboard.KeyboardEvent(event_type='up', scan_code=56, name='right alt')
    if x.event_type == a.event_type and x.scan_code == a.scan_code:
        win32api.mouse_event(win32con.MOUSEEVENTF_WHEEL, 0, 0, -800)
        # print("滚动了")
    if x.event_type == b.event_type and x.scan_code == b.scan_code:
        pass

#这是按键控制的
def abcff(kkoo,x):
    a = keyboard.KeyboardEvent(event_type='down', scan_code=57, name='space')
    b = keyboard.KeyboardEvent(event_type='up', scan_code=56, name='right alt')
    if x.event_type == a.event_type and x.scan_code == a.scan_code:
        win32api.mouse_event(win32con.MOUSEEVENTF_WHEEL, 0, 0, kkoo)
        # print(kkoo)
        # print("滚动了")
    if x.event_type == b.event_type and x.scan_code == b.scan_code:
        pass

def space_contral_scroll():
    try:
        keyboard.hook(abc)
        keyboard.wait('esc')
        print("你按下esc键，程序结束")
    except Exception as ess:
        print(f"自动截图运行出错,错误信息：\n{ess}")

def space_contral_scroll_have_num(kkoo):
    try:
        keyboard.hook(partial(abcff,kkoo))
        keyboard.wait('esc')
        print("你按下esc键，程序结束")
    except Exception as ess:
        print(f"自动截图运行出错,错误信息：\n{ess}")

if __name__ == '__main__':

    pass